package com.qsmx.store.app.main.mem;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatEditText;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;

import com.qsmx.store.app.R;
import com.qsmx.store.app.R2;
import com.qsmx.store.app.fustion.FustionTag;
import com.qsmx.store.app.main.mem.entity.MemManagerEntity;
import com.qsmx.store.app.util.StringUtil;
import com.qsmx.store.core.delegates.AtmosDelegate;

import butterknife.BindView;
import butterknife.OnClick;

public class MemCardPropertySaveTicketDelegate extends AtmosDelegate {

    private MemManagerEntity mMemManagerDate;

    @BindView(R2.id.tv_mem_card_ticket_num)
    AppCompatTextView tvMemCardTicketNum;
    @BindView(R2.id.tv_mem_ticket_use_time)
    AppCompatTextView tvMemTicketUseTime;
    @BindView(R2.id.et_mem_ticket_save_num)
    AppCompatEditText etMemTicketSaveNum;
    @BindView(R2.id.et_mem_remark)
    AppCompatEditText etMemRemark;

    @OnClick(R2.id.tv_sure)
    void onSure() {

    }

    @Override
    public Object setLayout() {
        return R.layout.delegate_mem_card_property_save_ticket;
    }

    public static MemCardPropertySaveCoinDelegate create(MemManagerEntity memManagerData) {

        final Bundle args = new Bundle();
        args.putSerializable(FustionTag.MEM_CARD_INFO, memManagerData);

        final MemCardPropertySaveCoinDelegate delegate = new MemCardPropertySaveCoinDelegate();
        delegate.setArguments(args);
        return delegate;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final Bundle args = getArguments();
        if (args != null) {
            mMemManagerDate = (MemManagerEntity) args.getSerializable(FustionTag.MEM_CARD_INFO);
        }
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {

        tvMemTicketUseTime.setText(StringUtil.getDateByTimestamp(StringUtil.getStringToDateTimeNoT(mMemManagerDate.getCreateTime()) + (long) (mMemManagerDate.getIcCard().getMemberGrade().getGradeValidDays() * 24 * 60 * 60 * 1000)));
        tvMemCardTicketNum.setText(String.valueOf(mMemManagerDate.getMemberProperty().getTickets()));

    }
}
